<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: WuLiangHang
  Date: 2021/3/11
  Time: 16:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--遍历1-10 输出
    begin属性设置开始的索引
    end属性设置结束的索引
    var 属性 表示当前正在遍历到的数据
    step 步长
--%>
<c:forEach begin="1" end="10" var="i" step="2">
    <h1>${i}</h1>
</c:forEach>

<%--
    遍历Object数组
    items:遍历的数据源
    var:当前遍历到的数据
--%>
<%
    request.setAttribute("arr", new String[]{"123", "456", "789"});
%>
<c:forEach items="${requestScope.arr}" var="item">
    ${item}<br/>
</c:forEach>
<%--
遍历Map集合
--%>
<%
    Map<String, Object> map = new HashMap<>();
    map.put("key1","value1");
    map.put("key2","value2");
    map.put("key3","value3");
    request.setAttribute("map", map);
%>
<c:forEach items="${requestScope.map}" var="entry">
    <h1>${entry.key} = ${entry.value} </h1>
</c:forEach>

<%--
通过foreach遍历存放Student的List集合 并且以table形式输出
List放10个学生
<table> <tr><td>
--%>
</body>
</html>
